package com.pj.wisdomlogistics.ui.activity;

import android.content.Intent;
import android.support.annotation.IdRes;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.pj.wisdomlogistics.R;
import com.pj.wisdomlogistics.cons.Cons;
import com.pj.wisdomlogistics.other.EventCenter;
import com.pj.wisdomlogistics.ui.view.AutoRadioGroup;
import com.pj.wisdomlogistics.utils.ActivityManagerUtil;

import butterknife.BindView;
import butterknife.OnClick;

public class ChooseTakeoutActivity extends BaseActivity {
    @BindView(R.id.rb_shy)
    RadioButton mRbShy;
    @BindView(R.id.rb_zfdl)
    RadioButton mRbZfdl;
    @BindView(R.id.rg_st)
    AutoRadioGroup mRadioGroup;
    @BindView(R.id.tv_title)
    TextView mTvTitle;
    @BindView(R.id.tv_rule)
    TextView mTvRule;

    private int checkedSt = -1;

    @Override
    public void initView() {
        ultimateBar.setColorBar(ContextCompat.getColor(this, R.color.text_blue));
        mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (mRadioGroup.getCheckedRadioButtonId() == R.id.rb_shy) {
                    checkedSt = 0;
                } else if (mRadioGroup.getCheckedRadioButtonId() == R.id.rb_zfdl) {
                    checkedSt = 1;
                }
            }
        });

        mTvRule.setText("预定外卖规则：\n" +
                "1、预定时间：12：00-14：00。\n" +
                "2、16：00之前可以撤销预定的外卖并可以再次下单，每个用户每天只能有一单。\n" +
                "3、16：00之后可以进行取码取货，取码之后不可撤销,取货时间18：00-18：20.\n" +
                "4、面点：每天最多可选择两个品类，每个最多十个预订量。\n" +
                "5、熟食：每个品类只能预定一份。");

    }

    @Override
    public void initData() {

    }

    @Override
    public int getContentView() {
        return R.layout.activity_choose_takeout;
    }

    @Override
    public boolean isApplyEventBus() {
        return false;
    }

    @Override
    public boolean isApplyButterKnife() {
        return true;
    }

    @Override
    public void onEventCome(EventCenter eventCenter) {

    }


    @OnClick({R.id.iv_back, R.id.rb_shy, R.id.rb_zfdl})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                ActivityManagerUtil.create().finishActivity();
                break;
            case R.id.rb_shy:
            case R.id.rb_zfdl:
                Intent mIntent = new Intent(ChooseTakeoutActivity.this, TakeoutMealActivity.class);
                mIntent.putExtra(Cons.TakeoutMeal.CHECKED_ST, checkedSt);
                startActivity(mIntent);
                break;
        }
    }


}
